<template>
  <div class="car-item">
    <!-- {{product}} -->
    <div class="item-check-box">
      <check-botton :is-checked='product.checked' @click.native="checkClick" />
    </div>
    <div class="item-img">
     <img :src="product.image" />
    </div>
    <div class="item-center">
      <h6>{{product.title}}</h6>
      <!-- <p>{{product.title}}</p> -->
      <p class="item-text">
        <span class="price">￥{{product.price}}</span> 
        <span class="count">x{{product.count}}</span>
      </p>
    </div>
  </div>
</template>

<script>
import CheckBotton from 'components/content/checkButton/CheckBotton'
export default {
  name: 'CartListItem',
  data() {
    return {

    }
  },
  components:{
    CheckBotton
  },
  props:{
    product:{
      type:Object,
      default(){
        return {}
      }
    }
  },
  // 生命周期 - 创建完成（访问当前this实例）
  created() {

  },
  // 生命周期 - 挂载完成（访问DOM元素）
  mounted() {

  },
  methods:{
    checkClick(){
      this.product.checked = !this.product.checked
    }
  }
}
</script>
<style scoped>
/* @import url(); 引入css类 */
.car-item {
  /* border: 1px solid red; */
  /* background: chartreuse; */
  overflow: auto;
  display:flex;
  padding: 0.2rem;
}
.car-item div{
  justify-content: center;
}
.item-check-box {
  width: 10%;
  display: flex;
  align-items: center;
}
.item-img {
  width: 4.5rem;
  height: 5rem;
  border-radius: 10px;
  overflow: hidden;
  /* border: 1px solid black; */
  display: flex;
  align-items: center;
  margin: auto;
}
.item-img img {
  width: 100%;
  border-radius: 10px;
}
.item-center {
  position: relative;
  display: inline-block;
  width: 60%;
}
.item-center h6{
  margin: 0;
  font-size: 0.95rem;  
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1; 
  overflow: hidden; 
  text-overflow: ellipsis;
}
.item-text {
  position: absolute;
  width: 100%;
  bottom: 0;
  font-size: 0.85rem;
  padding: 5px;
  box-sizing: border-box;
}
.price {
  color: var(--color-text)
} 
.count {
  position: absolute;
  right: 0;
  color: black;
  
}
</style>
